题目: 某公司的雇员分为以下若干类: Employee:这是所有员工总的父类, 属性: 员工的姓名,员工的生日月份。 方法:getSalary(intmonth) 根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖励100 元。
SalariedEmployee:
Employee 的子类,拿固定工资的员工。
属性:月薪
HourlyEmployee:
Employee 的子类, 按小时拿工资的员工,每月工作超出160 小时的部分按照1.5 倍工资发放。
属性:每小时的工资、每月工作的小时数
SalesEmployee:
Employee 的子类,销售人员,工资由月销售额和提成率决定。
属性:月销售额、提成率
BasePlusSalesEmployee:
SalesEmployee 的子类,有固定底薪的销售人员,工资 由底薪加上销售提成部分。
属性:底薪。
根据要求创建 SalariedEmployee 、 HourlyEmployees 、SaleEmployee 和 BasePlusSalesEmployee四个类的对象各一个,
并计算某个月这四个对象的工资。
注意:要求把每个类都做成完全封装,不允许非私有化属性。
//Employee类
public class Employee{
private String name;
private int month;
private double salary;
//无参构造函数
public Employee(){
}
//有参构造函数
public Employee(String name,int month,double salary){
this.name=name;
this.month=month;
this.salary=salary;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setMonth(int month){
this.month=month;
}
public int getMonth(){
return month;
}
public void setSalary(double salary){
this.salary=salary;
}
public double getSalary(){
return salary;
}
public double getSalary(int month){
if(this.month == month){
salary += 100;
}
System.out.println("员工"+ getName()+"的薪水为:"+salary);
return salary;
}
}
//SalariedEmployee类
public class SalariedEmployee extends Employee{
private double salary1;
//无参构造函数
public SalariedEmployee(){
}
//有参构造函数
public SalariedEmployee(double salary1){
this.salary1=salary1;
}
public void setSalary1(double salary1){
this.salary1=salary1;
}
public double getSalary1(){
return salary1;
}
public double getSalary(int month){
if(this.getMonth() == month){
salary1 += 100;
}
System.out.println("该员工"+getName()+"的薪水为:"+salary1);
return salary1;
}
}
//HourlyEmployee类
public class HourlyEmployee extends Employee{
private int hour;
private double price;
private double salary2;
//无参构造函数
public HourlyEmployee(){
}
//有参构造函数
public HourlyEmployee(int hour,double price,double salary2){
this.hour=hour;
this.price=price;
this.salary2=salary2;
}
public void setHour(int hour){
this.hour=hour;
}
public int getHour(){
return hour;
}
public void setPrice(double price){
this.price=price;
}
public double getPrice(){
return price;
}
public void setSalary2(double salary2){
this.salary2=salary2;
}
public double getSalary2(){
return salary2;
}
public double getSalary(int month){
if( hour |